Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alwatr/node-fs

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alwatr/node-fs

Enhanced file system operations in Node.js with asynchronous queue to prevent parallel writes.

  • 1.1.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
177
decreased by-42.35%
Maintainers
0
Weekly downloads
 
Created
Source

Node FS

Enhanced file system operations in Node.js with asynchronous queue to prevent parallel writes.

Installation

yarn add @alwatr/node-fs

Features

  • Checks if a directory exists. If it doesn't, it creates the directory and all necessary subdirectories.
  • Before writing a file successfully, first writes it to a temporary path (path.tmp).
  • If a file already exists, renames and keeps the existing file at a backup path (path.bak).
  • If a write operation fails, the original file remains unchanged.
  • Includes readJson and writeJson functions that automatically parse and stringify JSON data.
  • Supports both synchronous and asynchronous read/write operations.
  • An asynchronous queue is used to prevent simultaneous write operations.
  • Fully written in TypeScript, includes type definitions.
  • Separate builds are provided for ESModule and CommonJS.
  • Zero dependencies, except for the nanolib library.
  • Includes a beautiful log feature, which uses the logger package from nanolib.

Usage

import {writeJson} from '@alwatr/node-fs';

const path = 'file.json';
await writeJson(path, {a: 1}); // wait to finish
writeJson(path, {a: 2}); // asynchronous write in queue
writeJson(path, {a: 3}); // asynchronous write in queue

const data = await readJson(path); // automatically wait for the queue to finish
console.log(data.a); // 3

Sponsors

The following companies, organizations, and individuals support Nanolib ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.

Exir Studio

Contributing

Contributions are welcome! Please read our contribution guidelines before submitting a pull request.

License

This project is licensed under the AGPL-3.0 License.

Keywords

FAQs

Package last updated on 02 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc